package com.challenge.smsdao.teachermanage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.challenge.smsbase.Domain.BaseEntity;
import com.challenge.smsdao.admin.domain.Role;
import com.challenge.smsdao.coursemanage.domain.Course;

import javax.persistence.*;
import java.util.List;

/**
 * maboqi
 */
@Entity     //注解实体层
public class Teacher extends BaseEntity<Long> {
    @Column
    private String number;
    @Column
    private String sex;         //性别
    @Column
    private String name;        //名字
    @Column
    private String password;    //密码
    @Column
    private String telephone;
    @Column
    private String address;
    @OneToOne   //数据库一对一
    @JoinColumn(name = "role_id",referencedColumnName = "id")
    private Role role;          //私有角色
    @JsonIgnoreProperties("teacher")
    @OneToMany(mappedBy = "teacher",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.LAZY)
    private List<Course> courses;    //课程表和老师一对多需要加上注解
    @JsonIgnoreProperties("teachers")
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "department_id")
    private Department department;
    /*
    get，set方法
     */

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public List<Course> getCourses() {
        return courses;
    }

    public void setCourses(List<Course> courses) {
        this.courses = courses;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "sex='" + sex + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", role=" + role +
                '}';
    }
}
